//
//  CardContentViewControll.m
//  ELife
//
//  Created by feng lu on 11-5-17.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "CardContentViewControll.h"


@implementation CardContentViewControll

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

-(void) setImagePathArray:(NSArray*)imagePath target:(id)target
{
    NSInteger x = 0;
    NSInteger y = 10;
    
    for (int i = 0; i<[imagePath count]; i++) {
        
        UIButton* but = [UIButton buttonWithType:UIButtonTypeCustom];
        but.frame = CGRectMake(x, y, 84, 72);
        [but setBackgroundColor:[UIColor clearColor]];
        but.tag = i;
        [but addTarget:target action:@selector(contentButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [but setImage:[UIImage imageNamed:[imagePath objectAtIndex:i]] forState:UIControlStateNormal];
        [self.view addSubview:but];
        x+=85;
        if (i!=0&&i%2 == 0) {
            x = 0;
            y += 90;
        }
    }
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
